import 'package:dio/dio.dart';
import 'http_config.dart';

class HttpRequest {
  static BaseOptions baseOptions =
      BaseOptions(baseUrl: baseURL, connectTimeout: 5000);
  static Dio dio = Dio(baseOptions);

  static Future<T> request<T>(String url,
      {String method = 'get', Map<String, dynamic> parameters}) async {
    Options options = Options(method: method);

    try {
      Response response = await dio.request<T>(url,
          queryParameters: parameters, options: options);
      return response.data;
    } on DioError catch (e) {
      throw e;
    }
  }
}
